<extend name="Base/base" />

<block name="main">
    <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            <i class="fa fa-calendar"></i>
			       地址管理
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">地址管理</a></li>
            <li class="active">编辑地址信息</li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <!-- right column -->
            <div class="col-md-12">
              <!-- Horizontal Form -->
              <div class="box box-primary">
                <div class="box-header with-border">
                  <h3 class="box-title"><i class="fa fa-plus"></i> 编辑地址信息</h3>
                </div><!-- /.box-header -->
                <!-- form start -->
                <form class="form-horizontal" action="__CONTROLLER__/update" method="post" onsubmit="return doSubmit()">
                  <input type="hidden" value="{$addr.id}" name="id">
                  <div class="box-body">
                    <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">用户名</label><span style="font-size:12px;color:#fc0;" id="user"></span>
                      <div class="col-sm-4">
                        <input type="input" class="form-control" name="username" placeholder="UserName" onblur="checkUserName()" onfocus="checkUser()" value="{$addr.username}" readonly>
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">收货人</label><span style="font-size:12px;color:#fc0;" id="name" ></span>
                      <div class="col-sm-4">
                        <input type="input" class="form-control" name="name" placeholder="Name" value="{$addr.name}"  onfocus="checkFName()" onblur="checkName()">
                      </div>
                    </div>
                     <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">性别</label><span style="font-size:12px;color:#fc0;" id="sex"></span>
                      <div class="col-sm-4">
                        <input type="radio" name="sex"  value="1" <eq name="addr.sex" value="1">checked</eq>>男
                        <input type="radio" name="sex"  value="0" <eq name="addr.sex" value="0">checked</eq>>女
                        <input type="radio" name="sex"  value="" <eq name="addr.sex" value="">checked</eq>>未知
                      </div>
                    </div>
                     <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">地址</label><span style="font-size:12px;color:#fc0;" id="phone"></span>
                      <div class="col-sm-4">                         
                          <select class="form-control" name="address">
                            <option value="">--请选择辖区--</option>
                            <option value="1" <eq name="addr.address" value="1">selected</eq>>小店区</option>
                            <option value="2" <eq name="addr.address" value="2">selected</eq>>迎泽区</option>
                            <option value="3" <eq name="addr.address" value="3">selected</eq>>杏花岭区</option>
                            <option value="4" <eq name="addr.address" value="4">selected</eq>>尖草坪区</option>
                            <option value="5" <eq name="addr.address" value="5">selected</eq>>万柏林区</option>
                            <option value="6" <eq name="addr.address" value="6">selected</eq>>晋源区</option>                      
                          </select>
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">详细地址</label><span style="font-size:12px;color:#fc0;" id="phone"></span>
                      <div class="col-sm-4">
                        <input type="input" class="form-control" name="detail_add" placeholder="Phone" value="{$addr.detail_add}" >
                      </div>
                    </div>
                    <div class="form-group">
                      <label for="inputEmail3" class="col-sm-2 control-label">手机号</label><span style="font-size:1=2px;color:#fc0;" id="phone"></span>
                      <div class="col-sm-4">
                        <input type="input" class="form-control" name="phone" placeholder="Phone" value="{$addr.phone}"  onfocus="checkFPhone()" onblur="checkPhone()">
                      </div>
                    </div>
                  
                    
                  </div><!-- /.box-body -->
                  <div class="box-footer">
          				    <div class="col-sm-offset-2 col-sm-1">
          						    <button type="submit" class="btn btn-primary">修改</button>
                      </div>
          					  <div class="col-sm-1">
          						    <button type="submit" class="btn btn-primary">重置</button>
          					  </div>
                  </div><!-- /.box-footer -->
                </form>
				        <div class="row"><div class="col-sm-12">&nbsp;</div></div>
              </div><!-- /.box -->
       
            </div><!--/.col (right) -->
          </div>   <!-- /.row -->
        </section><!-- /.content -->
</block>
<block name="myscript">
  <literal>
      <script type="text/javascript">
          //表单提交限制
          function doSubmit() {
            return checkUserName()&&checkEmail()&&checkPhone();
          }
          //检测用户名
          function checkUser() {
            var user = $("input[name='username']").val();
            $("#user").html("账号由5-12位字母、数字或下划线组成");
            $("#user").css("color","#fc0");
          }          
          function checkUserName() {
            var user = $("input[name='username']").val();
            if(user.match(/^[a-zA-Z0-9_]{5,12}$/)==null){
                 $("#user").html("请输入正确的账户格式");
                 $("#user").css("color","red");
                return false;
            }else if(user.match(/(^\_)|(\__)|(\_+$)/)){
                $("#user").html("用户名首尾不能出现下划线\'_\'");
                $("#user").css("color","red");
                return false;
            }else if(user.match(/^\d+\d+\d$/)){
                 $("#user").html("用户名不能全为数字");
                 $("#user").css("color","red");
                return false;
            }else{
                 $("#user").html("");
                 $("#user").css("color","#fc0");
                 return true;
            }

          }
          //检测邮箱
          function checkEm() {
            var email = $("input[name='email']").val();
            $("#email").html("邮箱格式为：xxx@xx.xx");
            $("#email").css("color","#fc0");
          }
          function checkEmail() {
            var email = $("input[name='email']").val();
            if(email.match(/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/)==null){
                 $("#email").html("请输入正确的邮箱");
                 $("#email").css("color","red");
                return false;
            }else{
                 $("#email").html("");
                 $("#email").css("color","#fc0");
                 return true;
            }
          }

          //检测name
          function checkFName() {
              $("#name").html("请填写昵称");
              $("#name").css("color","#fc0");
          }
          function checkName() {
              $("#name").html("");
          }
          //检测地址
          function checkFAddr(){
            $("#address").html("请填写您的所在地名称");
            $("#address").css("color","#fc0");
          }
          function checkAddr(){
            $("#address").html("");
            $("#address").css("color","#fc0");
          }
          //检测手机
          function checkFPhone(){
              $("#phone").html("请正确填写电话");
              $("#phone").css("color","#fc0");
          }
          function checkPhone(){
              var phone = $("input[name='phone']").val();
              if (phone) {
                if (phone.match(/^1[34578]\d{9}$/)==null) {
                  $("#phone").html("格式不正确呢");
                  $("#phone").css("color","red");
                  return false;
                }else{
                  $("#phone").html("");
                  $("#phone").css("color","#fc0");
                  return true;
                }
              }else{
                $("#phone").html("");
                return true;
              }
          }

          //选择了配送员
          function peisong(state){
              if (state!=4) {
                $("#peisong").css("display","block");
              }
          }
      </script>
  </literal>
</block>